package com.mark.media.controller.v1;

import com.mark.common.media.constans.WmMediaConstans;
import com.mark.media.apis.MaterialManageControllerApi;
import com.mark.media.service.MaterialService;
import com.mark.model.common.dtos.ResponseResult;
import com.mark.model.media.dtos.WmMaterialDto;
import com.mark.model.media.dtos.WmMaterialListDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description :  java类作用描述
 * @Author :  Markburt
 * @CreateDate :  2020/3/8$ 下午 02:23$
 * @UpdateUser :  Markburt
 * @UpdateDate :  2020/3/8$ 下午 02:23$
 * @UpdateRemark :  Project Build
 * @Version :  1.0
 */
@RestController
@RequestMapping("/api/v1/media/material")
public class MaterialManageController implements MaterialManageControllerApi {


    @Autowired
    private MaterialService materialService;


    /***
     * 上传图片
     * @param file
     * @return
     */
    @Override
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile file) {
        return materialService.uploadPicture(file);
    }

    /**
     * 删除图片
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/del_picture")
    public ResponseResult delPicture(WmMaterialDto dto) {
        return materialService.delPicture(dto);
    }


    /**
     * 分页查询列表
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/list")
    public ResponseResult list(WmMaterialListDto dto) {
        return materialService.findList(dto);
    }

    /***
     * 收藏
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/collect")
    public ResponseResult collectionMaterial(WmMaterialDto dto) {
        return materialService.changeUserMaterialStatus(dto, WmMediaConstans.COLLECT_MATERIAL);
    }


    /***
     * 取消收藏
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/cancel_collect")
    public ResponseResult cancelCollectionMaterial(WmMaterialDto dto) {
        return materialService.changeUserMaterialStatus(dto,WmMediaConstans.CANCEL_COLLECT_MATERIAL);
    }
}
